package com.mmy.fta.cargo.server.util;

import com.github.pagehelper.PageInfo;
import com.mmy.fta.cargo.server.dto.CargoBlackboardPageDTO;
import com.mmy.fta.cargo.server.dto.CargoBlackboardPageRequestDTO;

/**
 * @author guohao.xie
 * @apiNote
 * @exportable
 * @since 2021/10/24
 */
public class PageUtils {
    /**
     * 将分页信息封装到统一的接口
     * @return
     */
    public static CargoBlackboardPageDTO getPageResult(CargoBlackboardPageRequestDTO pageRequest, PageInfo<?> pageInfo) {
        CargoBlackboardPageDTO pageResult = new CargoBlackboardPageDTO();
        pageResult.setPageNum(pageInfo.getPageNum());
        pageResult.setPageSize(pageInfo.getPageSize());
        pageResult.setTotalSize(pageInfo.getTotal());
        pageResult.setTotalPages(pageInfo.getPages());
        pageResult.setList(pageInfo.getList());
        return pageResult;
    }
}
